
    <?php  Yii::app()->clientScript->registerCoreScript('jquery')?>
    <script src="http://maps.google.com/maps/api/js?v=3.1&sensor=true" type="text/javascript"></script>

    <script type="text/javascript">
    
        function init() {

            $.ajax({
                type: "GET",
                url: "/index.php/imgs/Ajax_google_allshop",
                data: "d",
                success: function(msg){

			var myLatlng = new google.maps.LatLng(msg.outshop[0]['latitude'],msg.outshop[0]['longitude']);
			  var myOptions = {
				zoom: 12, center: myLatlng, disableDefaultUI: true,mapTypeControl: false, mapTypeId: google.maps.MapTypeId.ROADMAP 
			  }
			  var shop = <?php echo Yii::app()->request->baseUrl; ?>'/images/shop.png';
			  var factory = <?php echo Yii::app()->request->baseUrl; ?>'/images/factory.png';
			  var depot = <?php echo Yii::app()->request->baseUrl; ?>'/images/depot.png';
			  var map = new google.maps.Map(document.getElementById("map"), myOptions);
	                  function setMarckersshop(map,locations){
                    	
                        for(var i = 0;i < locations.length;i++){
                            if(locations[i].type ==0){var image = shop;};
                            if(locations[i].type ==1){var image = factory;};
                            if(locations[i].type ==2){var image = depot;};
                            var number = locations[i].number;
                            var longitude = locations[i].longitude;
                            var latitude = locations[i].latitude;
                            var address = locations[i].content;
                            var title = address;
                            var mylatlng = new google.maps.LatLng(latitude,longitude);
                            var marker = new google.maps.Marker({                    
                                position: mylatlng,                    
                                map: map,
                                icon: image
                            });
                            set_event(map,marker,title);
                        }    
                    }                                              	
                        function set_event(map,marker,title){
                            //设置窗口显示信息
                            var infowindow = new google.maps.InfoWindow({                    
                                content: title
                            });
                            //注册图标事件
                            google.maps.event.addListener(marker,'mouseover',function() {    
                                    infowindow.open(map,marker);
                            });               
                            google.maps.event.addListener(marker, 'mouseout',function() {                  
                                    infowindow.close();
                            });
                        }
                    
                                     
//          	     array = msg;
                    setMarckersshop(map,msg.outshop);                  	


                },
                dataType:'json'
            });
		}
    </script>

<body onLoad="init();">
<div id="map" style="width:650px; height:800px;"></div>
